<%--
  -	Date: 2012-07-30
  -
  - Copyright (C) 2012 Jawa Software. All rights reserved.
  - 
  - 试题管理页面。
--%>
<%@page import="org.jawa.admin.util.Page"%>
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@ page import="org.jawa.admin.util.ParamUtils,org.jawa.core.util.*,org.jawa.core.JawaServer,org.jawa.exam.model.Question,org.jawa.exam.model.QuestionOption"
	        	 
%>
<%@ page import="java.util.Collection,java.util.List,java.util.ArrayList"
%>
<%@ page import="org.apache.commons.lang.StringUtils"%>

<jsp:useBean id="webManager" class="org.jawa.admin.util.WebManager"  />
<% 
    webManager.init(request, response, session, application, out);
	String path = request.getContextPath();
%>

<%
     
	int range = ParamUtils.getIntParameter(request, "range", 20);
	int start = webManager.getPageIndex(range,"row");
	
	Page currentPage = new Page(start,range);
	
	List<Question> questions = webManager.getQuestionManager().getQuestions(currentPage);
	
	request.setAttribute("questions",questions);
	request.setAttribute("page",currentPage);

%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>管理试题</title>
		<meta name="pageID" content="2104" />
	</head>
	<body>
		<div class="row-fluid">

			<ul class="breadcrumb">
				<li>
					您现在的位置:
				</li>
				<li>
					<a href="<%=path%>/admin/index.jsp">考试管理</a>
				</li>
				<li>
					<span class="divider">/</span>
				</li>
				<li class="active">
					试题管理
				</li>
			</ul>

			<form action="index.jsp" method="post" class="form-search well">
				<div class="row-fluid ">
						<label class="query-label">
							试题类型:
						</label>
						<input type="text" name="brId" value="" class="input-small " >
						<label class="query-label">
							试题名称:
						</label>
						<input type="text" name="loginNo" value="" class="input-small " >
						<label class="query-label">
							试题分值:
						</label>
						<input type="text" name="userName" value="" class="input-small " >
						<input type="submit" name="search" class="btn btn-primary" value="查询">
				</div>
			</form>
			<div class="subnav ">
				<div class=" btn-toolbar pull-right ">
						<a class="btn btn-success " href="question-form.jsp"><i class="icon-user icon-white"></i>创建试题</a>
				</div>
				<div class="btn-toolbar pull-left">
						<%
							if("true".equals(request.getParameter("create")) && "true".equals(request.getParameter("success"))) 
							{
						%>
						<p class="alert alert-success">
							<a class="close" data-dismiss="alert" href="#">×</a> 创建试题成功!
						</p>
						<%  
							} 
						%>
				</div>	
			</div>
			<display:table id="row" name="questions" partialList="true" 
						pagesize="${page.pageSize}" size="${page.totalCount}" requestURI="index.jsp" export="false"
						class="table table-striped table-bordered table-condensed">
				<display:column title="序号"  style="width:70px;text-align:center">
				   <c:out value="${row_rowNum}"></c:out>
				</display:column>
				<display:column title="试题类型"  style="width:120px;text-align:center">
					<c:if test="${row.questionType eq '1'}">
					   单选题 
					</c:if>
					<c:if test="${row.questionType eq '2'}">
					  多选题
					</c:if>
					<c:if test="${row.questionType eq '3'}">
					  判断题 
					</c:if>
					<c:if test="${row.questionType eq '4'}">
					   问答题 
					</c:if>
				</display:column>
				<display:column property="questionContent" title="试题内容" maxLength="18" />
				<display:column title="试题难度"  style="width:100px;">
					<c:if test="${row.difficulty eq '1'}">
					   容易
					</c:if>
					<c:if test="${row.difficulty eq '2'}">
					  难
					</c:if>
					<c:if test="${row.difficulty eq '3'}">
					  困难 
					</c:if>
				</display:column>
				<display:column property="questionScore" title="试题分值" style="width:70px;" />
				<display:column title="操作" style="width:110px;text-align:center">
					    <div class="btn-group">
							<a href="#" onclick="return deleteUser('${row.questionId }');" class="btn btn-mini"><i class="icon-trash "></i>删除</a>
							<a href="question-form.jsp?edit=true&id=${row.questionId}" class="btn btn-mini"><i class="icon-edit "></i>修改</a>
					    </div>
				</display:column>
			</display:table>
			
		</div>

		<script src="<%= path %>/scripts/bootstrap.js"></script>
		<script>
			function deleteUser(userId){
				if(confirm('你确定要删除当前用户吗?')){
					window.location.href='user-form.jsp?delete=true&userId='+userId;
				}
			}
		</script>
		
	</body>